package com.supersit.greensproject.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.supersit.greensproject.R;
import com.supersit.greensproject.service.NetworkStateService;
import com.supersit.greensproject.utils.AppManager;
import com.supersit.greensproject.utils.AppUtils;
import com.supersit.greensproject.utils.T;
import com.supersit.greensproject.view.ShowDialog;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by cong on 2016/7/12.
 */
@ContentView(R.layout.activity_splash)
public class SplashActivity extends BaseActivity {
    private Context context;
    @ViewInject(R.id.versionNumber)
    private TextView ivVersion;
    private String versionName;
    private ShowDialog showDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
//        setContentView(R.layout.activity_splash);
        x.view().inject(this);
        context = this;
        showDialog = new ShowDialog(context);
        versionName = AppUtils.getVersionName(context);
        ivVersion.setText("当前版本:" + versionName);
        transition();
    }

    private void transition() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent i = new Intent(context, LoginActivity.class);
                startActivity(i);
                //启动主Activity后销毁自身
                finish();
            }
        }, 3000);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }
}
